Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix project-local flags being ignored #8623

Merged
merged 2 commits into from
Dec 26, 2022

Conversation

bairyn
Copy link
Collaborator

@bairyn bairyn commented Dec 3, 2022

This was originally the first of two parts to the ‘Track static vs. dynamic dependencies.’ pull request (#8461), which I've cleaned up and split into two separate PRs.

This PR fixes an issue in which configuration flags such as ‘--disable-library-vanilla’ could be silently dropped when a package was built and installed, and it also adds a test that sets up a scenario to demonstrate the issue.

(I ran the cabal-testsuite/PackageTests test suite and found ‘432 tests, 6 skipped, 0 unexpected passes, 0 unexpected fails’.)

@Mikolaj Mikolaj added type: enhancement re: dynamic-linking Concerning dynamic linking (e.g. flags "shared", "*-dynamic") labels Dec 4, 2022
@bairyn bairyn force-pushed the fix-project-local-flags branch from cf42086 to a087092 Compare December 10, 2022 02:06
@bairyn
Copy link
Collaborator Author

bairyn commented Dec 10, 2022

I just pushed amendments to this MR that update the remaining tests (along with a rebase), outside PackageTests (isolated changes: bairyn@6446120).

@gbaz
Copy link
Collaborator

gbaz commented Dec 10, 2022

Thanks for the thoroughness of this PR and tests, for being responsive to the ask to refactor the big PR, and especially for your patience in explaining it in all the details! All very much appreciated.

@gbaz
Copy link
Collaborator

gbaz commented Dec 10, 2022

I'm approving as is, but it would be great to add a changelog entry to the changelog dir as well.

@bairyn bairyn force-pushed the fix-project-local-flags branch from a087092 to e38e2f8 Compare December 22, 2022 07:02
I noticed that running ‘cabal install’ with two separate sets of dynamic /
static build flags (e.g. one with none, and one with ‘--enable-shared
--enable-executable-dynamic --disable-library-vanilla’) produced packages with
the same hash, instead of different hashes.

After debugging this issue I found that this command (with no explicit cabal
project file) was resulting in these build configuration flags being ignored,
because in ProjectPlanning.hs, the sdist was not considered a local package, so
the (non-shared) local-package-only configuration was being dropped.

This fix ensures that these command-line arguments properly make it through to
where they belong in cases like this.

Additionally, adjust the ‘style’ attribute in plan.json so that globally
installed packages are designated as global even if they are local to the
project.  (Without this adjustment to ‘style2str’, the T5782Diamond test fails,
because it looks up ‘dist-dirs’ in plan.json, where ‘dist-dirs’ is absent from
the JSON.)

Finally, take into account elabDynExe and configDynExe to provide GHC with
‘-dynamic’ appropriately rather than going about it with static linking.
@bairyn bairyn force-pushed the fix-project-local-flags branch from e38e2f8 to 2334bcb Compare December 22, 2022 07:12
@bairyn
Copy link
Collaborator Author

bairyn commented Dec 22, 2022

Thanks gbaz.

I just updated this MR with the following updates:

  • Rebased onto upstream, so it's more up-to-date.
  • Added changelog entry.
  • Skip the new test on Windows (I noticed the tests I added fail on Windows for some reason; I'll just skip them on Windows for now).

@Mikolaj
Copy link
Member

Mikolaj commented Dec 22, 2022

@bairyn: was that the same failure as on OSX currently? It would be ideal to understand it in both cases.

@bairyn bairyn force-pushed the fix-project-local-flags branch from 2334bcb to 867cbb9 Compare December 23, 2022 00:45
@bairyn
Copy link
Collaborator Author

bairyn commented Dec 23, 2022

No, they're different. I think what happened in the OS X case is that the Grinch stole the vowels from the package names, so when the test looks for ‘basic-0.1-’ to extract the hash (as it's done in UniqueIPID), it can't find it because it isn't looking for ‘bsc-0.1-’. I just pushed an update to the hash extraction utility to also check for ‘bsc-0.1-’, so that the utility in the test works also on OS X.

I think what happened in the Windows case is that the installation I set up (with Chocolatey) and the one that the CI server uses don't support dynamic builds. I set up a VM to reproduce the scenario, and I found that just creating a simple ‘cabal init’ application with ‘--enable-shared --enable-executable-dynamic --disable-library-vanilla’ fails with an error since the dynamic files are missing for the ‘base’ package. I updated the note around ‘skipIfWindows’.

MR Updates:

  • Search for ‘bsc-0.1-’, so that the new test supports OS X.
  • Add note about skipping on Windows (needs support for dynamic builds).

Copy link
Member

@Mikolaj Mikolaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot and especially for the test.

Please set one of the merge_me labels and in 2 days it should get auto-merged.

@bairyn bairyn added the merge me Tell Mergify Bot to merge label Dec 24, 2022
@mergify mergify bot added the merge delay passed Applied (usually by Mergify) when PR approved and received no updates for 2 days label Dec 26, 2022
@mergify mergify bot merged commit 13e704d into haskell:master Dec 26, 2022
@Mikolaj
Copy link
Member

Mikolaj commented Feb 1, 2023

Hi there! Heads up that we most probably need to improve this PR before we can release cabal 3.10. The main issue is raised in #8721, some more information is in #8723 and both of these link to some other related tickets. Comments welcome. Ideas welcome. Experiments welcome.

@phadej
Copy link
Collaborator

phadej commented Feb 1, 2023

@Mikolaj the main issue is #8719

@Mikolaj
Copy link
Member

Mikolaj commented Feb 1, 2023

#8719 is the release blocker and we hope it will fall out of #8721, which is the main task at hand, if the current investigation is accurate. If it's not solved by #8721, we have to re-asses. Anyway, everything is linked from the two tickets I mentioned.

@phadej
Copy link
Collaborator

phadej commented Feb 1, 2023

#8721 won't solve #8719. The plan.json change is only masking the breaking changes done elsewhere. The proper fix is #8723, but it essentially reverts what this patch did.

@phadej
Copy link
Collaborator

phadej commented Feb 1, 2023

To be clear: I don't think you can have this patch and fix #8719 at the same time. local tarballs should not be affected by flags meant for local packages.

The fact v2-install --lib is done how it is is unfortunate.

There should be a way to explicitly tell that "when you install/build/.. package foo apply these flags to package foo", that would be generally useful too. (And we can do that in cabal.project, I guess - and maybe the that can be done for fake project the v2-install --lib builds)

@Mikolaj
Copy link
Member

Mikolaj commented Feb 1, 2023

OK, I stand corrected.

@gbaz
Copy link
Collaborator

gbaz commented Feb 2, 2023

After examining this for a while I'm coming around to the point of view of @phadej

A way to see the issue is that I think that even with this PR, cabal install foo-pkg --disable-library-vanilla will ignore that flag if run on a package foo-pkg in a remote repo. Before that pr, this would fail also if run inside a cabal project. After this pr, if its run inside a project directory, it will apply the flag, but if its run on a remote package, it won't. That seems inconsistent. The design, for better or worse, is that cabal never lets you apply flags when running a v2-install. I don't think this fixes that underlying issue, it just confuses things further.

I think the change proposed in #8723 is the most straightforward (but I don't understand the comment about it breaking cabal install --lib ??). We would couple that with flipping the test.

I believe this PR actually packed in another change, which is applying the static and dynamic flags to the setup configs as well, and I think that should stick around. (That was actually the basis on which I had supported this PR to begin with, not realizing it packed in this other thing too!). So that's why I'd propose selective flipping that one line while keeping other refactors (which also seem generally useful), as opposed to a wholesale revert.

@Mikolaj
Copy link
Member

Mikolaj commented Feb 7, 2023

@bairyn: I haven't heard from you and we have to wrap up for the 3.10 (pre-)release. Are you OK with me reverting this PR wholesale on 3.10 and master branches and we can then slowly work our way towards salvaging the clarification and simplification ideas that are contained in it, using the @phadej input? Would that break any of your existing work, e.g., on the other PRs (I hope not, given they compile and test fine on just the bare master branch)?

Mikolaj added a commit to Mikolaj/cabal that referenced this pull request Feb 8, 2023
This reverts commit b547ead
from haskell#8623.
Unexpected side-effect has been found, so these code
improvements have to be done differently.
The other commit in the PR is a test and it's retained.
@Mikolaj
Copy link
Member

Mikolaj commented Feb 8, 2023

The (half-)reversion I'd propose is in #8744.

Mikolaj added a commit to Mikolaj/cabal that referenced this pull request Feb 14, 2023
This reverts commit b547ead
from haskell#8623.
Unexpected side-effect has been found, so these code
improvements have to be done differently.
The other commit in the PR is a test and it's retained.
mergify bot pushed a commit that referenced this pull request Feb 14, 2023
This reverts commit b547ead
from #8623.
Unexpected side-effect has been found, so these code
improvements have to be done differently.
The other commit in the PR is a test and it's retained.

(cherry picked from commit 533cbc1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge delay passed Applied (usually by Mergify) when PR approved and received no updates for 2 days merge me Tell Mergify Bot to merge re: dynamic-linking Concerning dynamic linking (e.g. flags "shared", "*-dynamic") type: enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants